import React, { Component } from "react";
import { connect } from "./connect";
import PropTypes from "prop-types";
class RX extends Component {
  static contextTypes = {
    store: PropTypes.object
  };
  changeUserName(target, value) {
    let time = +new Date();
    this.props.login({
      userName: `Carolie - ${time}--${name}`,
      password: "1111222"
    });
  }
  render() {
    // console.log("this.props:", this.props);
    // console.log("this.context:", this.context);
    const { userName } = this.props;
    return (
      <div>
        <div>这里是组件：userName => {userName}</div>
        <div>
          <button onClick={this.changeUserName.bind(this)}>修改用户名</button>
        </div>
      </div>
    );
  }
}
const mapToState = ({ store }) => ({
  ...store
});

export default connect(mapToState)(RX);
// export default RX;
